import {defineStore} from 'pinia'


const userInfoStore = defineStore('userInfo',{
    state:()=>({
        userName:'',
        userId:'',
        userAllInfo:'',
        authorization:'',
        loginAccount:'',
    }),
    persist: true, //持久化
    actions:{
        updateAuthorization(authorization:string,loginAccount:string){
            this.authorization = authorization
            this.loginAccount = loginAccount
        },
        updateUserInfo(info:any){
            this.userName = info.username
            this.userId = info.userId
            this.userAllInfo = info
        },
        clearUserInfo(){
            this.$reset()
        }
    }
})

export default userInfoStore